<%--
  User: qw
  Date: 2020/10/25
  Time: 15:16
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>组队广场</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
    <link rel="Shortcut Icon" href="../../images/logo.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/bootstrap.css">
    <style>
        #div1  {
            vertical-align: top;
            box-sizing: border-box;
            transition: all .5s;
            -webkit-transition: all .5s; /* Safari */
        }
        #div1:hover {
            cursor: pointer;
            transform: scale(1.03);
            -ms-transform:scale(1.03);     /* IE 9 */
            -moz-transform:scale(1.03);     /* Firefox */
            -webkit-transform:scale(1.03); /* Safari 和 Chrome */
            -o-transform:scale(1.03);
        }
    </style>
</head>
<body>
<!-- 头部导航栏 -->
<%@ include file="../header.jsp"%>
<!-- 小头部-->
<section >
    <div class="container">
        <div class="row mt-3">
            <div class="ml-4 col-md-5 col-sm-12">
                <h3 class="d-inline-block">组队广场</h3><small class="pl-3">在组队广场找到志同道合的小伙伴吧^_^</small>
            </div>
        </div>
        <div class="row mt-3">
            <div class="col">
                <ul class="nav">
                    <li class="nav-item">
                        <a class="nav-link disabled" href="#">分类：</a>
                    </li>
                    <li class="nav-item ${url == '/cooperation/selectAll?currentPageIndex=' ? 'active' : ''}">
                        <a class="nav-link" href="${path}/cooperation/selectAll?currentPageIndex=1">全部</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"
                           href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=1">比赛类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"
                           href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=2">设计类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"
                           href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=3">文艺类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"
                           href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=4">创作类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link"
                           href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=5">公益类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="${path}/cooperation/selectByCid?currentPageIndex=1&cid=7">其他</a>
                    </li>
                    <li class="nav-item" style="margin-left: 10px;">
                        <form class="form-inline" action="/cooperation/searchCooperation">
                            <div class="form-group">
                                <input type="text" hidden name="currentPageIndex" value="1">
                                <input type="text" class="form-control" name="str" style="margin-right: 10px; height: 34px;" placeholder="搜组队、搜要求..."/>
                            </div>
                            <button type="submit" class="btn btn-primary" style="border-radius: 30px;">搜索</button>
                        </form>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</section>

<!-- 内容 -->
<section>
    <div class="container">
        <div class="row">
            <div class="col-12">
                <c:forEach items="${resultInfo.data.cooperationList}" var="cooperationList">
                    <div class="card  mt-3" id="div1">
                        <div class="row no-gutters">
                            <div class="col-md-8">
                                <div class="card-body">
                                    <h6 class="card-title font-weight-bold">
                                        <c:set value="${cooperationList.catalog.cid}" var="cid"/>
                                        <span class="badge badge-${cid==1?'primary':(cid==2?'info':(cid==3?'success':(cid==5?'danger':(cid==4?'warning':(cid==6?'secondary':'dark')))))} pr-2 mr-2">${cooperationList.catalog.cname}</span>
                                        <a class="text-decoration-none" href="${path}/cooperation/selectByCoid?coid=${cooperationList.coid}">${cooperationList.title}</a>
                                    </h6>
                                    <p class="card-text">
                                        <small>招募要求:</small><small class="text-muted ml-2" style="max-width: 50px;">${cooperationList.demand}</small>
                                        <small class="ml-2">发布于: </small><small class="text-muted">${cooperationList.publish_time}</small>
                                        <small class="ml-2">截止于: </small><small class="text-muted">${cooperationList.end_time}</small>
                                    </p>
                                </div>
                            </div>
                            <div class="col-md-4 text-center pt-2">
                                <div class="d-none  d-md-block">
                                    <img src="../..${cooperationList.user.photo}" class="card-img rounded-circle shadow-sm" style="width: 60px; height: 60px" alt="...">
                                </div>
                                <small class="d-block pl-2 text-primary">@${cooperationList.user.username}</small>
                            </div>
                        </div>
                    </div>
                </c:forEach>
            </div>
            <div class="col-12 mt-3">
                <nav aria-label="Page navigation example">
                    <ul class="pagination justify-content-center">
                        <%--如果页数为0 则不展示分页符--%>
                        <c:if test="${resultInfo.data.pageCount > 1}">
                            <%--上一页按钮--%>
                            <c:if test="${url == '/cooperation/selectAll?currentPageIndex='}">
                                <c:set var="href" value="${path}${url}${currentPageIndex - 1}"/>
                                <li class="page-item ${currentPageIndex - 1 <= 0 ? 'disabled' : ''}">
                                    <a class="page-link" href="${href}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                            </c:if>
                            <c:if test="${url == '/cooperation/selectByCid?'}" var="href">
                                <c:set var="href"
                                       value="${path}${url}currentPageIndex=${currentPageIndex - 1}&cid=${cid}"/>
                                <li class="page-item ${currentPageIndex - 1 <= 0 ? 'disabled' : ''}">
                                    <a class="page-link" href="${href}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                            </c:if>
                            <%--遍历页数--%>
                            <c:forEach begin="1" end="${resultInfo.data.pageCount}" var="pageIndex">
                                <c:if test="${url == '/cooperation/selectAll?currentPageIndex='}">
                                    <c:set var="href" value="${path}${url}${pageIndex}"/>
                                    <li class="page-item ${currentPageIndex == pageIndex ? 'active' : ''}"><a
                                            class="page-link" href="${href}">${pageIndex}</a></li>
                                </c:if>
                                <c:if test="${url == '/cooperation/selectByCid?'}" var="href">
                                    <c:set var="href"
                                           value="${path}${url}currentPageIndex=${pageIndex}&cid=${cid}"/>
                                    <li class="page-item ${currentPageIndex == pageIndex ? 'active' : ''}"><a
                                            class="page-link" href="${href}">${pageIndex}</a></li>
                                </c:if>
                            </c:forEach>
                            <%--下一页按钮--%>
                            <c:if test="${url == '/cooperation/selectAll?currentPageIndex='}">
                                <c:set var="href" value="${path}${url}${currentPageIndex + 1}"/>
                                <li class="page-item ${currentPageIndex + 1 > resultInfo.data.pageCount ? 'disabled' : ''}">
                                    <a class="page-link" href="${href}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </c:if>
                            <c:if test="${url == '/cooperation/selectByCid?'}" var="href">
                                <c:set var="href"
                                       value="${path}${url}currentPageIndex=${currentPageIndex - 1}&cid=${cid}"/>
                                <li class="page-item ${currentPageIndex + 1 > resultInfo.data.pageCount ? 'disabled' : ''}">
                                    <a class="page-link" href="${href}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </c:if>
                        </c:if>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</section>

<!-- 退出登录的模态框 -->
<div class="modal fade" id="logoffModal" tabindex="-1" role="dialog" aria-labelledby="logoffModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="prompt-text">点击"确定"退出账号</div>
                <div class="bgimg_lf"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">确定</button>
            </div>
        </div>
    </div>
</div>

<!--引入JQuery,再引入popper.js，最后引入bootstrap.js-->
<script src="../../js/jquery.min.js"></script>
<script src="../../js/bootstrap.bundle.js"></script>
<shiro:authenticated>
    <script src="/js/message.js"></script>
</shiro:authenticated>
</body>
</html>
